package com.service;

import com.entity.ShopGoods;
import com.mapper.ShopGoodsMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service("shopGoodsService")
public class ShopGoodsServiceImp implements ShopGoodsService {

    @Autowired
    ShopGoodsMapper shopGoodsMapper;

    @Override
    public int getGoodsCount(String name) {
        return shopGoodsMapper.getGoodsCount(name);
    }

    @Override
    public List<ShopGoods> findGoodsByPage(Integer currentPage, Integer pageSize, String name) {
        Integer startIndex = (currentPage - 1) * pageSize;
        return shopGoodsMapper.selectGoodsByPage(startIndex, pageSize, name);
    }

    @Override
    public ShopGoods findByPrimaryKey(Integer id) {
        return shopGoodsMapper.selectByPrimaryKey(id);
    }

    @Override
    public int modifyByPrimaryKeySelective(ShopGoods record) {
        return shopGoodsMapper.updateByPrimaryKeySelective(record);
    }

    @Override
    public int addSelective(ShopGoods record) {
        return shopGoodsMapper.insertSelective(record);
    }

    @Override
    public int removeByPrimaryKey(Integer id) {
        return shopGoodsMapper.deleteByPrimaryKey(id);
    }
}
